package com.jinzhi.jzweb.controller.moduleConfig;


import com.jinzhi.common.base.BaseController;
import com.jinzhi.common.utils.Result;
import com.jinzhi.jzweb.pojo.moduleConfig.RecordPointsDO;
import com.jinzhi.jzweb.strategy.factory.PayStrategyFactory;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * 
 * <pre>
 * 考生报名   第一次加密
 * </pre>
 * <small> 2023-05-05 08:52:02 | lance</small>downloadImportStu
 */
@Controller
@RequestMapping("/recordPoints")
@Api(value = "录分管理", tags = "录分管理")
public class RecordPointsController extends BaseController {


	private final PayStrategyFactory payStrategyFactory;

	public RecordPointsController(PayStrategyFactory payStrategyFactory) {
		this.payStrategyFactory = payStrategyFactory;
	}



	@ApiOperation(value = "录分导出", notes = "录分导出")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "field", value = "赛场", required = true, dataType = "String"),
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@GetMapping("/downloadMark")
	@ResponseBody
	public void downloadMark(HttpServletResponse response,String field)  throws Exception {
		payStrategyFactory.get(field).downloadImportTemplate(response,field);
	}

	@ApiOperation(value = "机考分数导出", notes = "机考分数导出")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "field", value = "赛场A", required = true, dataType = "String"),
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@GetMapping("/downloadImportBased")
	@ResponseBody
	public void downloadImportBased(HttpServletResponse response,String field)  throws Exception {
		payStrategyFactory.get(field).downloadImportBased(response,field);
	}


	@ApiOperation(value = "录分", notes = "录分")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "resultsComDO", value = "录分信息", required = true, dataType = "RecordPointsDO")
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@PostMapping("/recordPoints")
	@ResponseBody
	public Result recordPoints(@RequestBody RecordPointsDO resultsComDO) throws Exception {
		return payStrategyFactory.get(resultsComDO.getField()).recordPoints(resultsComDO);
	}


	@ApiOperation(value = "根据赛场分页查询录分信息", notes = "根据赛场分页查询录分信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "field", value = "赛场", required = true, dataType = "String"),
			@ApiImplicitParam(name = "current", value = "当前页", required = true, dataType = "Integer"),
			@ApiImplicitParam(name = "size", value = "每页条数", required = true, dataType = "Integer"),
	})
	@ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
			@ApiResponse(code = 500, message = "服务器内部异常")})
	@GetMapping("/getScoreInfoPage")
	//@RequiresPermissions("jzweb:getScoreInfoPage:getScoreInfoPage")
	@ResponseBody
	public Result getScoreInfoPage(String field,Integer current,Integer size) throws Exception {
		return payStrategyFactory.get(field).getScoreInfoPage(field,current,size);
	}

}
